package vg.modules.notepad.components.textComponent;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JComponent;
import javax.swing.JPanel;

/**
 * This class realizes row header for text pane.
 * @author tzolotuhin
 */
public class ScrollPaneRowHeader {
	private final JPanel view;
	private final List<JComponent>components;
	/**
	 * Constructor.
	 */
	public ScrollPaneRowHeader() {
		this.view = new JPanel(new GridBagLayout());
		this.components = new ArrayList<JComponent>();
	}
	/**
	 * This method adds new row to header of text pane.
	 */
	public synchronized void addRow(final JComponent row) {
		GridBagConstraints gbc = new GridBagConstraints(this.components.size(),0, 1,1, 0,1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0,0);
		this.view.add(row, gbc);
		this.components.add(row);
	}
	public synchronized JPanel getView() {
		return(this.view);
	}
}
